<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">

        <?php
        echo $html->css("nivo-slider.css");
        echo $html->css("style 2.css");
        echo $html->css("frontend.css");
        echo $html->css("jquery.wysiwyg.css");
        echo $javascript->link("jquery-1.6.1.min.js");
        echo $javascript->link("jquery.nivo.slider.pack.js");
        echo $javascript->link("jquery.wysiwyg.js");
        ?>

        <script type="text/javascript">
            
            $(document).ready(function(){
                $('#box_main').append('<div id="top">Back to top</div>');
                $(window).scroll(function() {
                    if($(window).scrollTop() !=0){
                        $('#top').fadeIn();
                    } else{
                        $('#top').fadeOut();	
                    }
                });	
                $('#top').click(function(){
                    $('html,body').animate({scrollTop:0},500);
                });
            });
	
            $(window).load(function() {
                $('#slider').nivoSlider();
            });
        </script>
        <style>
            .anh{
                width:300px;
                float:left;
                border-right:1px;
                border-right-color:#666;
            }
            .tin{
                width:300px;
                float:left;
            }
            .dai{
                width:100px;
                height:30px;
            }
        </style>


    </head>
    <body>
    
          <div class="box-main">

            <div class="box-main-left">
                <div class="pro-content">
                    <div class="box-pro-highlights">
                        <div class="box-pro-highlights-header">Sản Phẩm </div>
                        <div class="content">
                            <table cellpadding="8" cellspacing="8">
                                <tr valign="center">
                                    <td width="300px">
                                        <img width="75%" height="80%" class="img-bo" src="/onlinemarket/img/San_pham/<?php echo $vProduct['Product']['picture']  ?>"/>
                                    </td>
                                    <td style="text-align: left">
                                      <p>
                                        <b style="font-size:16px;font-weight: bold;"><?php echo $vProduct['Product']['name'] ?> </b>
                                      </p> 
                                      <br/>                                                                            
                                      <p>
                                           - <b style="font-size:.9em;">Giá sản phẩm: <span style="color:#a11818;font-weight: normal"><?php echo number_format($vProduct['Product']['price'],0,'.','.') ?> VNĐ</span></b> 
                                      </p>
                                      <br/>
                                      <p >                                          
                                           - <b style="font-size:.9em;">Người bán: 
                                               <?php foreach($shop as $vshop) :
                                                if($vshop['Shop']['id']==$vProduct['Product']['shop_id']){ 
                                                 ?>
                                               <span style="color:#a11818;font-weight: normal">
                                                 <?php  echo($vshop['Shop']['name']); ?>
                                                   <?php } ?>
                                               </span>
                                             </b> 
                                           <?php endforeach; ?>
                                      </p>
                                      <br/>
                                      <p>
                                          - <b style="font-size:.9em;">
                                              Số lượng :<?php if($vProduct['Product']['quantity']>0){ ?>
                                              <span><?php echo $vProduct['Product']['quantity']; } else{ echo("<b>Hết Hàng</b>"); }?></span>
                                          </b>
                                      </p>  
									  <p >                
											<?php
												foreach($offsales as $offsale){
													if($offsale['Offsale']['product_id']== $vProduct['Product']['id']){
											?>
                                           <b style="font-size:.7em;">Khuyến mại 
                                                <span style="color:#a11818;font-weight: normal">
                                                 <?php  echo($offsale['Offsale']['type']); ?>
                                                </span><br/>
											   Giá mới:<span style="color:#a11818;font-weight: normal">
                                                 <?php  echo(number_format($offsale['Offsale']['new_price'],0,'.','.')); ?>
                                                </span><br/>
												Từ ngày:<span style="color:#a11818;font-weight: normal">
                                                 <?php  echo($offsale['Offsale']['begin_date']); ?>
                                                </span><br/>
												Đến ngày<span style="color:#a11818;font-weight: normal">
                                                 <?php  echo($offsale['Offsale']['end_date']); ?>
                                                </span><br/>
												<span style="color:#a11818;font-weight: normal">
                                                 <?php  echo($offsale['Offsale']['description']); ?>
                                                </span>
                                             </b> 
                                           <?php } } ?>
                                      </p>									  
                                      <p style="margin-top: 15px;">
                                          <img class="add" pid="<?php echo $vProduct['Product']['id']; ?>" src="/onlinemarket/img/system/addtocart.gif"/>
                                          <a href="/onlinemarket/frontends/viewcart"><img src="/onlinemarket/img/system/viewcart.jpg"/></a>
                                      </p>
									  <br/>
									   
                                    </td>
                                </tr>                                
                            </table>
                            
                        </div>
                        <!--hien thi thuoc tinh san phảm-->
                        <div class="content">
                            <div class="box-pro-highlights-header"> Chi Tiết Thông tin sản phẩm </div>
                            <table cellspacing="5" cellpadding="5">
                                <?php
                                foreach ($parametersp as $param) {
                                    if ($param['ParametersProduct']['product_id'] == $vProduct['Product']['id']) {
                                        ?>
                                        <tr>
                                            <?php
                                            foreach ($paramsp as $pa) {
                                                if ($pa['Parameter']['id'] == $param['ParametersProduct']['parameter_id']) {
                                                    ?>
                                                    <td class="dai"><font color=blue><?php
                                    echo $pa['Parameter']['name'];
                                }
                            };
                            ?></font> </td><td> :</td>
                                            <td><font size=2px><?php echo $param['ParametersProduct']['value'] ?></font></td>
                                        </tr>
    <?php }
} ?>
                            </table>
                            <div class="box-pro-highlights-header"> Gửi ý kiến của bạn </div>
                            <form id="form-comment" action="/onlinemarket/comments/save" method="POST">
                                <input type="hidden" name="pid" value="<?php echo $vProduct['Product']['id']; ?>"/>
                            <table>
                                <tr>
                                    <td style="width:400px"><textarea name="content" id="description" rows="4" cols="70"></textarea></td>                                    
                                </tr>
                                <tr>
	
                                    <td><img src="/onlinemarket/img/system/send.png" class='addcm' pidcm="<?php echo $vProduct['Product']['id']; ?>"/></td>
                                </tr>
								</table>
								
                                <?php
                                foreach ($comments as $comment) {
                                    if ($comment['Comment']['status'] == 1 and $comment['Comment']['product_id']==$vProduct['Product']['id']) {
                                        ?>
										<div style="margin:5px;padding:5px;border:1px solid #ccc;">
                                        
                                            Người Gửi : <?php 
											foreach($customer as $cus){
											if($cus['Customer']['id']== $comment['Comment']['customer_id']){
												echo($cus['Customer']['username']); ?>
                					-Ngày : <?php echo($comment['Comment']['date']);} } ?> </br>

                                            
                                           <p style="margin:5px;padding:5px;border:1px solid #ccc;">Nội dung <font color="#000"><?php echo($comment['Comment']['cm_content']); ?></font></p>
                                        </div>
                                 <?php }  ?>
                                        <?php } ?>
                            
                            </form>

                        </div>

                        <script>
                            (function($)
        {
            $('#description').wysiwyg({
                controls: {
                    strikeThrough : { visible : true },
                    underline     : { visible : true },

                    separator00 : { visible : true },

                    justifyLeft   : { visible : true },
                    justifyCenter : { visible : true },
                    justifyRight  : { visible : true },
                    justifyFull   : { visible : true },

                    separator01 : { visible : true },

                    indent  : { visible : true },
                    outdent : { visible : true },

                    separator02 : { visible : true },

                    subscript   : { visible : true },
                    superscript : { visible : true },

                    separator03 : { visible : true },

                    undo : { visible : true },
                    redo : { visible : true },

                    separator04 : { visible : true },

                    insertOrderedList    : { visible : true },
                    insertUnorderedList  : { visible : true },
                    insertHorizontalRule : { visible : true },

                    h4mozilla : { visible : true && $.browser.mozilla, className : 'h4', command : 'heading', arguments : ['h4'], tags : ['h4'], tooltip : "Header 4" },
                    h5mozilla : { visible : true && $.browser.mozilla, className : 'h5', command : 'heading', arguments : ['h5'], tags : ['h5'], tooltip : "Header 5" },
                    h6mozilla : { visible : true && $.browser.mozilla, className : 'h6', command : 'heading', arguments : ['h6'], tags : ['h6'], tooltip : "Header 6" },

                    h4 : { visible : true && !( $.browser.mozilla ), className : 'h4', command : 'formatBlock', arguments : ['<H4>'], tags : ['h4'], tooltip : "Header 4" },
                    h5 : { visible : true && !( $.browser.mozilla ), className : 'h5', command : 'formatBlock', arguments : ['<H5>'], tags : ['h5'], tooltip : "Header 5" },
                    h6 : { visible : true && !( $.browser.mozilla ), className : 'h6', command : 'formatBlock', arguments : ['<H6>'], tags : ['h6'], tooltip : "Header 6" },

                    separator07 : { visible : true },

                    cut   : { visible : true },
                    copy  : { visible : true },
                    paste : { visible : true }    
                }
            });
        })(jQuery);
                            function onEdit(link) {
                                window.location = link;
                            }
                            $(function(){
                                $(".add").click(function(){
                                    var id = $(this).attr("pid");
                                    $.ajax({
                                        url:"/onlinemarket/frontends/addtocart/"+id,
                                        type:"Get",
                                        success:function(data){location.reload();}
                                    })
                                });
                            });	
                            $(function(){
                                $(".addcm").click(function(){
                                    var id = $(this).attr("pidcm");
                                    $.ajax({
                                        url:"/onlinemarket/comments/save",
                                        type:"POST",
                                        data:$("#form-comment").serialize(),
                                        success:function(data){location.reload();
                                        
                                        }
                                    })
                                });
                            });	
                        </script>
                    </div>
                </div><!--end div.box-pro-highlights-->
            </div><!--end div.pro-content-->
        </div><!--end div.box-main-left-->
        <div class="box-main-right" style="margin: 0px;"></div><!--end div.box-main-right-->

    </div><!--end div.box-main-->

    <div class="box_footer">

    </div><!--end div.footer-->
</body>
</html>